<?php

/**
 * This is the model class for table "{{article_data}}".
 *
 * The followings are the available columns in table '{{article_data}}':
 * @property string $id
 * @property integer $article_id
 * @property string $tag
 * @property string $content
 * @property string $coordinate
 * @property string $price_thumb
 * @property string $traffic_info
 * @property string $ticket_info
 * @property string $open_time
 * @property string $best_time
 * @property string $about_time
 * @property string $features
 * @property string $zhusu_info
 * @property string $food_info
 * @property string $happy_info
 */
class ArticleData extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{article_data}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('article_id', 'required'),
			array('article_id', 'numerical', 'integerOnly'=>true),
			array('tag, coordinate, best_time, about_time', 'length', 'max'=>100),
			array('price_thumb', 'length', 'max'=>120),
			array('features', 'length', 'max'=>255),
			array('content, traffic_info, ticket_info, open_time, zhusu_info, food_info, happy_info', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, article_id, tag, content, coordinate, price_thumb, traffic_info, ticket_info, open_time, best_time, about_time, features, zhusu_info, food_info, happy_info', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'article_id' => 'Article',
			'tag' => 'Tag',
			'content' => 'Content',
			'coordinate' => 'Coordinate',
			'price_thumb' => 'Price Thumb',
			'traffic_info' => 'Traffic Info',
			'ticket_info' => 'Ticket Info',
			'open_time' => 'Open Time',
			'best_time' => 'Best Time',
			'about_time' => 'About Time',
			'features' => 'Features',
			'zhusu_info' => 'Zhusu Info',
			'food_info' => 'Food Info',
			'happy_info' => 'Happy Info',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('article_id',$this->article_id);
		$criteria->compare('tag',$this->tag,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('coordinate',$this->coordinate,true);
		$criteria->compare('price_thumb',$this->price_thumb,true);
		$criteria->compare('traffic_info',$this->traffic_info,true);
		$criteria->compare('ticket_info',$this->ticket_info,true);
		$criteria->compare('open_time',$this->open_time,true);
		$criteria->compare('best_time',$this->best_time,true);
		$criteria->compare('about_time',$this->about_time,true);
		$criteria->compare('features',$this->features,true);
		$criteria->compare('zhusu_info',$this->zhusu_info,true);
		$criteria->compare('food_info',$this->food_info,true);
		$criteria->compare('happy_info',$this->happy_info,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return ArticleData the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
